package com.gvitz.transaction.activities;


import android.content.Context;
import android.content.SharedPreferences;
import android.graphics.Typeface;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import com.gvitz.transaction.R;
import com.gvitz.transaction.database.webserviceUser;
import com.gvitz.transaction.utils.validations.Field;
import com.gvitz.transaction.utils.validations.Form;
import com.gvitz.transaction.utils.validations.NotEmpty;

public class BlockedActivity extends GVActivity  {

	
    private EditText mCodigo;   
    private Button mSubmit;
    private Form mForm;
    SharedPreferences prefs= null;
   

	@SuppressWarnings("unused")
	@Override
	public void onCreate(Bundle savedInstanceState) {
	         
	        super.onCreate(savedInstanceState);
	        setContentView(R.layout.activity_blocked);
        
    	
        prefs =  getSharedPreferences("preferencias", Context.MODE_PRIVATE);
        
		SharedPreferences.Editor editor = prefs.edit();	
        
        mCodigo = (EditText) findViewById(R.id.codigo_blocked);
        mSubmit = (Button) findViewById(R.id.submit_blocked);
        
        Typeface font = Typeface.createFromAsset( getAssets(), "fonts/fontawesome-webfont.ttf" );
	      
        TextView t = (TextView) findViewById(R.id.icon_codigo_bloqued);
        t.setTypeface(font);
        
        mForm = new Form(this);
        mForm.addField(Field.using(mCodigo).validate(NotEmpty.build(this)));
        
        mSubmit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

		 		if (mForm.isValid()) {
		 					 			
		 		//Verificar codigo		        	
		 			webserviceUser w = new webserviceUser(getApplicationContext(),BlockedActivity.this);
		        	w.Recover(prefs.getString("id_usuario",""),mCodigo.getText().toString());         		 
            	}
            }
        });
	}
			
	}
         
   	